package com.gtw.modules.api.controller;

import com.gtw.common.utils.R;
import com.gtw.modules.api.service.TbOrderService;
import com.gtw.modules.entity.TbExpressCode;
import com.gtw.modules.entity.TbOrder;
import com.gtw.modules.sys.service.TbExpressCodeService;
import com.gtw.utils.JuHeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/** 快递查询
 * Created by wuye on 2018/3/27.
 */
@RestController
@RequestMapping("/api/express")
public class ExpresscodeController {

    @Autowired
    private TbOrderService tbOrderService;

    @Autowired
    private TbExpressCodeService tbExpressCodeService;

    /**
     * 查询
     * @return 订单编号
     */
    @RequestMapping("/found")
    public R foundExpress(@RequestParam String billno){
        TbOrder tbOrder = tbOrderService.queryBybillno(billno);
        String result = JuHeUtils.getRequest1(tbOrder);
        return R.ok().put("data",result);
    }


    /**
     * 查询所有快递信息
     * @return
     */
    @RequestMapping("/foundList")
    public R foundList(){
        List<TbExpressCode> list = tbExpressCodeService.foundAll();
        return R.ok().put("data",list);
    }
}
